package templateInherit;

import java.util.Map;
import java.util.Optional;

public class Main {

	public static void main(String[] args) {
		ObjectBase objectBase = new MonsterObject();
		
		ObjectManager objectManager = new ObjectManager();

		objectManager.getOptionalObj(MonsterObject.class).ifPresent(o -> {
			System.out.println(o.getObjectType().toString());
		});

		System.out.println(":" + objectManager.getOptionalObj(MonsterObject.class)
			.map(o->o.getObjectType())
			.orElse(ObjectType.Base)
			.toString()
			);
		
		System.out.println();
		
		Map<String, UnitObject> mons = objectManager.getObjs(UnitObject.class);
		
		System.out.println("mons size:" + mons.size());
		
		
		MonsterObject monsterObj = new MonsterObject();
		if (monsterObj instanceof UnitObject) {
			System.out.println("monsterObj instanceof UnitObject1");
		}
		
		ObjectBase base = monsterObj;
		
		if (UnitObject.class.isInstance(monsterObj)) {
			System.out.println("monsterObj instanceof UnitObject2");
		}
		
		HumanObject humanObject = new HumanObject();
		
		UnitObject unitObject = humanObject;
		
		try {
			MonsterObject monsterObject = (MonsterObject)unitObject;
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
		
		
		
		System.out.println("finished.");
	}
	
	

}
